using System.Collections.Generic;
using UnityEngine;

public class gamebackctl : MonoBehaviour
{
	public static gamebackctl instance;

	public GameUIState curstate;

	public List<GameUIState> prestate;

	private void Awake()
	{
		if (instance == null)
		{
			instance = this;
		}
		prestate = new List<GameUIState>();
	}

	private void Start()
	{
	}

	private void Update()
	{
		if (UnityEngine.Input.GetKeyUp(KeyCode.Escape) && !GlobalInf.gamefirst)
		{
			switch (curstate)
			{
			case GameUIState.loading:
				break;
			case GameUIState.result:
				break;
			case GameUIState.normal:
				UIController.instance.pausegame(null);
				break;
			case GameUIState.pauselevel:
				GameUIController.instance.disable_pauseui_level();
				break;
			case GameUIState.pausedtb:
				GameUIController.instance.disable_pause_dtb();
				break;
			case GameUIState.pauseffa:
				GameUIController.instance.disable_pause_ffa();
				break;
			case GameUIState.pausesur:
				GameUIController.instance.disable_pause_sur();
				break;
			case GameUIState.pausetdm:
				GameUIController.instance.disable_pause_tdm();
				break;
			case GameUIState.option:
				GameUIController.instance.disable_optionui();
				break;
			case GameUIState.piece:
				GameUIController.instance.disable_pieceui();
				break;
			case GameUIState.rank:
				GameUIController.instance.disable_rankui();
				break;
			case GameUIState.rate:
				GameUIController.instance.resultuilevel_win.dis_rate();
				break;
			case GameUIState.inter:
				GameUIController.instance.disable_inter();
				break;
			case GameUIState.relive:
				GameUIController.instance.disabel_relive();
				break;
			}
		}
	}

	public void ChangeGameUIstate(GameUIState newstate)
	{
		prestate.Add(curstate);
		curstate = newstate;
	}

	public void BackGameUIstate()
	{
		if (prestate.Count > 0)
		{
			curstate = prestate[prestate.Count - 1];
			prestate.RemoveAt(prestate.Count - 1);
		}
	}

	private void OnDestroy()
	{
		if (instance != null)
		{
			instance = null;
		}
	}
}
